//    https://www.nowcoder.com/questionTerminal/99fa7be28d5f4a9d9aa3c98a6a5b559a



#include <iostream>
#include <string>
using namespace std;

bool yes[100];

bool check(int x)
{
    string s = to_string(x);
    for (int i = 0; i < s.size(); i++)
        for (int j = s.size() - 1; j >= 0; j--)
        {
            if (s[i] == '0' || i == j) continue;
            int num = 10 * (s[i] - '0') + (s[j] - '0');
            if (yes[num]) return true;
        }
    return false;
}

int main()
{
    int a, b;
    cin >> a >> b;
    yes[11] = yes[13] = yes[17] = yes[19] = yes[23] = yes[29] = yes[31] = yes[37] = yes[41] = yes[43] = yes[47] = yes[53] = yes[59] = yes[61] = yes[67] = yes[71] = yes[73] = yes[79] = yes[83] = yes[89] = yes[97] = true;
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        if (i < 11) continue;
        ans += check(i);
    }
    cout << ans;
    return 0;
}